<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<title>车位分配</title>
    <base href="<%=basePath%>"> 
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/vivo.css">
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	
	<script src="js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script> 
    <script type="text/javascript" src="js/sharefunction.js"></script>
    <script language="javascript" type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script>
    <link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
	<script type="text/javascript">
		
		$(document).ready(function() {
			var s1=$("#customerType").select2();
			var s2=$("#carType").select2();
			var s3=$(".js-example-basic-single").select2();
			initSelectData();
			initSelectData2();
			s1.val("租户").trigger("change");
			s2.val("大型客车").trigger("change");
			$("#panel2-1").hide();
			$("#panel2-2").hide();
		});
		
		$(".js-example-tags").select2({ 
		    tags: true
		})
		    
		function initSelectData(){
			var html = "";
			var arr = ["租户","员工","其他"];
			for(var i = 0;i<arr.length;i++){
				html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
				$("#customerType").append(html);
			}
		}
		
		function initSelectData2(){
			var html = "";
			var arr = ["大型客车","中型客车","小型汽车","小型越野车","摩托车"];
			for(var i = 0;i<arr.length;i++){
				html = "<option value=\""+arr[i]+"\">"+arr[i]+"</option>";
				$("#carType").append(html);
			}
		}
		
		function change(obj){
			var val = $(obj).val();
			if(val=='0'){
				$("#panel1").show();
				$("#panel2-1").hide();
				$("#panel2-2").hide();
			}else {
				$("#panel1").hide();
				$("#panel2-1").show();
				$("#panel2-2").show();
			}
		}
		
		function saveDocument(){
			var projectId=$("#projectId").val();
			var customerId=$("#customerId").val();
			var customerType=$("#customerType").val();
			var carType=$("#carType").val();
			var brandName=$("#brandName").val();
			var carColor=$("#carColor").val();
			var carNumber=$("#carNumber").val();
			var carportType=$("#carportType").val();
			var carportLocation=$("#carportLocation").val();
			var fkcarportNumber=$("#fkcarportNumber").val();//车位号外键
			var buyTime=$("#buyTime").val();
			var leaseType=$("#leaseType").val();
			var staleaseDate=$("#staleaseDate").val();
			var endleaseDate=$("#endleaseDate").val();
			var adduserid = '${user.id}';
			var AccessoryCaList=$("#AccessoryCaList").val();
			var url="project/decorateManager/addCar";
			$.ajax({
			    type:"post",
			    async:false,
			    url:url,
		        dataType:"json",
		        data:{
		        	projectId:projectId,
		        	customerId:customerId,
		        	customerType:customerType,
		        	carType:carType,
		        	brandName:brandName,
		        	carColor:carColor,
		        	carNumber:carNumber,
		        	carportType:carportType,
		        	carportLocation:carportLocation,
		        	fkcarportNumber:fkcarportNumber,//车位号
		        	buyTime:buyTime,
		        	leaseType:leaseType,
		        	staleaseDate:staleaseDate,
		        	endleaseDate:endleaseDate,
		        	adduserid:adduserid,
		        	AccessoryCaList:AccessoryCaList 
		        },
			    success:function(responseText){
			        if(responseText.success){
						//window.parent.gridObj_1.refreshPage();
			        	window.parent.layer.msg('保存成功！');
			        	closeIframe();

	    			}else{
	    				alert(responseText.msg, {icon: 7});
	    			}
			    }
	   		});
		}
		
		function doSearch(){
			var id = $("#projectId").val();
			var url = "customer/parkingPlaceInfo/tolist3/"+id;
			openTitleLayer("查找车位 ",url,800,600);
		}
	</script>
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
		<div style="padding:10px 20px">
		
		<div class="panel panel-default">
			<div class="panel-heading">
      				<h5 class="panel-title">车辆信息</h5>
   			</div>
   			<div class="panel-body">
			<table cellpadding="10" cellspacing="5" class="mytable">
				<tr height="45">
					<td width="90">楼盘</td>
					 <td style="width:280px;">
				    	<input type="text" name="projectName" id="projectName" value="${ri.buildingInfo.projectInfo.projectName}" readOnly/> 
				    	<input type="hidden" name="projectId" id="projectId" value="${ri.buildingInfo.projectInfo.id}" readOnly/> 
					 </td>
					<td width="90" >使用人</td>
					<td>
						<!-- 客户外键  待完善 -->
						<input type="text" name="usePeople" id="usePeople" value="" /> 
						<input type="hidden" name="customerId" id="customerId" value="" /> 
					</td>
					
				</tr>
				<tr>
					<td width="90">客户类型</td>
					<td>
						<select class="js-example-basic-single" name="customerType" id="customerType"  style="width:90px;">
							
						</select>
					</td>
					
					<td width="90" >车型</td>
					<td>
						<select class="js-example-basic-single" name="carType" id="carType"  style="width:90px;">
						</select>
					</td>
				</tr>
				<tr>
					
					<td width="100">品牌名称</td>
					<td >
						<input type="text" id="brandName" name="brandName" />
					</td>
					<td width="100" >颜色</td>
					<td >
						<input type="text" id="carColor" name="carColor" />
					</td>
				</tr>
				<tr>
					<td width="90">车牌号</td>
					<td>
						<input type="text" name="carNumber" id="carNumber" /> 
						<span></span>
					</td>
					<td width="90">车位使用情况</td>
					<td>
						<select class="js-example-basic-single" name="carportType" id="carportType" style="width:70px;"  onchange="change(this)" >
							<option value="0" selected>租赁</option>
							<option value="1">购买</option>
						</select>
					</td>
				</tr>
			</table>
			<fieldset>
				<legend>租赁/购买</legend>
				<table>
					<tr>
						<td width="70" height="60">位置</td>
						<td width="290">
							<input type="text" name="carportLocation" id="carportLocation" readonly/> 
						</td>
						<td width="70">车位号</td>
						<td>
							<input type="text" name="number" id="number" size="5" readonly/>
							<input type="hidden" name="fkcarportNumber" id="fkcarportNumber" size="5"/>
							&nbsp;&nbsp;<a class="btn btn-primary radius" onClick="doSearch(this)">选择</a> 
						</td>
						<td width="70" id="panel2-1">购买时间</td>
						<td id="panel2-2">
							<input type="text" name="buyTime" id="buyTime" class="Wdate" onClick="WdatePicker()"/> 
						</td>
					</tr>
					<tr id="panel1">
						<td>租赁</td>
						<td>
							<select class="js-example-basic-single" name="leaseType" id="leaseType" style="width:70px;" >
								<option value="0" selected>直租</option>
								<option value="1">转租</option>
							</select>
						</td>
						<td>租赁期限</td>
						<td colspan="3">
							<input type="text" name="staleaseDate" id="staleaseDate" class="Wdate" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'endleaseDate\',{d:0});}'})"/>
							至<input type="text" name="endleaseDate" id="endleaseDate" class="Wdate" onClick="WdatePicker({minDate:'#F{$dp.$D(\'staleaseDate\',{d:0});}'})"/>
						</td>
					</tr>
				</table>
			</fieldset>
			<br>
			<table >
				<tr >
					<!-- 驾驶证 -->
					<td colspan="2">
						<!-- 附件上传 -->
						<%@include file="../../p_utilePage/Article.jsp" %>
					</td>
				</tr>
			</table>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius"  onclick="saveDocument()"> 保 存</button> 
				 <a class="btn btn-default radius" onClick="closeIframe();"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
		</div>
		<div style="display:none">
			<input type="hidden" name="roomId" id="roomId" value="${roomInfoId} "/>
	    </div>
		</form>
  	</body>
  	
   </html>
